// var markers = [];
// var circles = [];
var map, // 高德地图对象
    mapStyle1 = "amap://styles/4f5a03a9ca38c0c6ed169bd03b9a1a72", // 各乡镇地图样式（无乡镇信息）
    mapStyle2 = "amap://styles/26b864777a3ae3391f26485d6614ffe8", // 普通地图样式（由乡镇信息）
    mapImg1 = "img/index/map-img-1.png", // 乡镇资源图
    mapImg2 = "img/index/map-img-2.jpg", // 旅游资源图
    xzArr = [
        "梧桐镇",
        "盘谷乡",
        "大洋镇",
        "长庆镇",
        "洑口乡",
        "嵩口镇",
        "塘前乡",
        "同安镇",
        "清凉镇",
        "樟城镇",
        "葛岭镇",
        "岭路乡",
        "赤锡乡",
        "城峰镇",
        "丹云乡",
        "富泉乡",
        "红星乡",
        "东洋乡",
        "盖洋乡",
        "白云乡",
        "霞拔乡"
    ],
    xcArr =["晋安区","闽侯县", "长乐区",  "福清市", "连江县", "鼓楼区", "罗源县", "高新区", "永泰县", "仓山区", "马尾区", "闽清县","台江区"],
    xzLnglats = [
        [118.758485,25.735127], // 梧桐镇
        [118.814252,25.979626], // 盘古乡
        [118.790106,25.919329], // 大洋镇
        [118.595209,25.887089], // 长庆镇
        [118.482526,25.766368], // 洑口乡
        [118.600959,25.802806], // 嵩口镇
        [119.160926,25.869405], // 塘前乡
        [118.768834,25.839232], // 同安镇
        [118.935559,25.90477], // 清凉镇
        [118.918933,25.856095],// 樟城镇
        [119.081496,25.878377], // 葛岭镇
        [118.938491,25.816047], // 岭路乡
        [118.864557,25.778082], // 赤锡乡
        [118.963532, 25.867277], // 城峰镇
        [119.027732, 25.990458], // 丹云乡
        [118.88147, 25.836049], // 富泉乡
        [118.843664, 25.997121], // 红星乡
        [118.64606, 25.910898], // 东洋乡
        [118.495174,25.844175], // 盖洋乡
        [118.91362, 26.03031], // 白云乡
        [118.695461, 25.925199] // 霞拔乡
    ];
/**
 * [navCtr 导航样式控制]
 * @return {[type]} [description]
 */
function navCtr() {
    $('a[data-toggle="tab"]').on("click", function (e) {
        if ($(e.target).text() == "旅游" || $(e.target).text() == "农业") {
            $(".left-nav li").removeClass("active");
        }
    });
    $("#main-nav-cy a").on("click", function (e) {
        $(".main-nav li").removeClass("active");
        $("#main-nav-cy").addClass("active");
    });
}

/**
 * [aMap 地图]
 * @type {Object}
 */
var aMap = {
    /**
     * [init 地图初始化]
     * @return {[type]} [description]
     */
    init: function () {
        map = new AMap.Map("map-gd", {
            zoom: 10,
            center: [118.7908, 25.868236],
            mapStyle: mapStyle1
        });
    },
    xzSet: function (xzCenter) {
        map.setCenter(xzCenter);
    },
    /**
     * [addMapBorder 设置描边]
     * @return {[type]} [description]
     */
    addMapBorder: function () {
        //加载行政区划插件
        AMap.service("AMap.DistrictSearch", function () {
            var opts = {
                subdistrict: 1, //返回下一级行政区
                extensions: "all", //返回行政区边界坐标组等具体信息
                level: "city" //查询行政级别为 市
            };
            //实例化DistrictSearch
            district = new AMap.DistrictSearch(opts);
            district.setLevel("district");
            //行政区查询
            district.search("永泰县", function (status, result) {
                var bounds = result.districtList[0].boundaries;
                var polygons = [];
                if (bounds) {
                    for (var i = 0, l = bounds.length; i < l; i++) {
                        //生成行政区划polygon
                        var polygon = new AMap.Polygon({
                            map: map,
                            strokeWeight: 1,
                            path: bounds[i],
                            fillOpacity: 0.1,
                            fillColor: "#fff",
                            strokeColor: "#5042F6"
                        });
                        polygons.push(polygon);
                    }
                }
            });
        });
    },
    /**
     * [createInfoWindow 构建自定义信息窗体]
     * @param  {[type]} title [信息标题]
     * @return {[type]}       [description]
     */
    createInfoWindow: function (title) {
        var count = parseInt(title.bigS)+parseInt(title.bigT)
        var info =
            '\
            <div class="map-info"> \
             <h3>' + title.name + '</h3> \
                 <ul> \
                      <li>产业：'+count+'个</li> \
                      <li>园区：'+title.bigN+'个</li> \
                      </ul> \
             </div>'
        return info;
    },
    /**
     * [addCountyMasker 添加乡镇坐标点]
     */
    addCountyMasker: function (gxzLnglats,gxzName) {
        console.log(gxzLnglats,gxzName);
        var _this = this;
        // 各镇坐标点
        var infoWindow = new AMap.InfoWindow({
            isCustom: true, //使用自定义窗体
            offset: new AMap.Pixel(16, -30)
        });
        for (var i = 0; i < gxzLnglats.length; i++) {
            var marker = new AMap.Marker({
                position: gxzLnglats[i],
                map: map,
                icon: new AMap.Icon({
                    size: new AMap.Size(38, 38), //图标大小
                    imageSize: new AMap.Size(38, 38),
                    image: "http://download.huashitong.net/map-point.png",
                    imageOffset: new AMap.Pixel(0, 0)
                })
            });
            marker.setLabel({
                //label默认蓝框白底左上角显示，样式className为：amap-marker-label
                offset: new AMap.Pixel(0, 25), //修改label相对于maker的位置
                content: gxzName[i].name
            });
            marker.setAnimation("AMAP_ANIMATION_DROP");
            marker.ExtData =  gxzName[i]// 自定义数据
            marker.content = _this.createInfoWindow(gxzName[i]);
            //marker弹出自定义的信息窗体
            marker.on("mouseover", function (e) {
                infoWindow.setContent(e.target.content);
                infoWindow.open(map, e.target.getPosition());
            });
            marker.on("mouseout", function (e) {
                map.clearInfoWindow();
            });
            // 跳转乡镇
            marker.on("click", function (e) {
                console.log(e.target.ExtData);
                $('.modal-container').empty();
                //模态框
                $('.modal-container').html('')
                $('#resourceModal').modal('show');
                $.ajax({
                    url: "/modules/sys/resourceMaps/resourceQuery",
                    type: "POST",
                    dataType: "json", //返回数据形式为json
                    contentType: 'application/json;charset=UTF-8',
                    data: JSON.stringify({'type':e.target.ExtData.type,'resourceName':e.target.ExtData.name}),
                    success: function (res) {
                        if(res.code=="200"){
                            if(res.data != undefined){
                                var str=res.data[0].content;
                                $('.modal-container').html(escape2Html(str))
                                function escape2Html(str) {
                                    if(str !=undefined){
                                        var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
                                        return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
                                    }else{
                                        return '暂无数据'
                                    }
                                }
                            }
                        }
                    }
                });

                //地图
                // $('#map-tab').hide();
                // $('.xz-nav').show();
                // var op1 = [{
                //     lnglats: [118.843664,25.997121],
                //     name: '对项项目'
                // }]
                // xzCenter = [118.918933, 25.856095];
                // map.setMapStyle(mapStyle1);
                // map.clearMap();
                // aMap.xzSet(xzCenter);
                // aMap.addMapBorder();
                // aMap.addPointMasker(op1,'');
                // map.setFitView();
            });
        }
    },
    /**
     * [addTour 添加旅游坐标点]
     */
    addTour: function (option) {
        // 各旅游坐标点,半径
        var point = option;
        for (var i = 0; i < point.length; i++) {
            var circle = new AMap.Circle({
                map: map,
                center: point[i].lnglats, // 圆心位置
                radius: point[i].r, //半径
                strokeColor: "#FED147", //线颜色
                strokeOpacity: 1, //线透明度
                strokeWeight: 2, //线粗细度
                fillColor: "#FED147", //填充颜色
                fillOpacity: 0.35 //填充透明度
            });
            var text = new AMap.Text({
                map: map,
                text: point[i].name,
                textAlign: "center", // 'left' 'right', 'center',
                verticalAlign: "middle", //middle 、bottom
                style: {
                    "background-color": "rgba(0,0,0,0)",
                    border: "none",
                    padding: "10px 20px",
                    color: "#fff",
                    "font-size": "10px",
                    "text-shadow": "0px 0px 5px #000"
                },
                position: point[i].lnglats
            });
            console.log(circle);
            text.ExtData = point[i]; // 自定义数据
            text.on('click', function(e) {
                console.log(e.target.ExtData);
                $('#resourceModal').modal('show');
                $.ajax({
                    url: "/modules/sys/resourceMaps/resourceQuery",
                    type: "POST",
                    dataType: "json", //返回数据形式为json
                    contentType: 'application/json;charset=UTF-8',
                    data: JSON.stringify({'type':e.target.ExtData.type,'resourceName':e.target.ExtData.name}),
                    success: function (res) {
                        console.log(res);
                        if(res.code=="200"){
                            if(res.data != undefined){
                                var str=res.data[0].content;
                                $('.modal-container').html(escape2Html(str))
                                function escape2Html(str) {
                                    var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
                                    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
                                }
                            }
                        }
                    }
                });
            })

        }
    },
    addPointMasker: function (data, infoClass) {
        var _this = this;
        // 各镇坐标点
        var _infoWindow = new AMap.InfoWindow({
            isCustom: true, //使用自定义窗体
            offset: new AMap.Pixel(16, -30)
        });
        for (var i = 0; i < data.length; i++) {
            var marker = new AMap.Marker({
                position: data[i].lnglats,
                map: map,
                icon: new AMap.Icon({
                    size: new AMap.Size(38, 38), //图标大小
                    imageSize: new AMap.Size(38, 38),
                    image: "http://download.huashitong.net/map-point.png",
                }),
            });
            var text = new AMap.Text({
                map: map,
                text: data[i].name,
                textAlign: 'center', // 'left' 'right', 'center',
                verticalAlign: 'bottom', //middle 、bottom
                style: {
                    'background-color': 'rgba(0,0,0,0)',
                    'border': 'none',
                    'color': '#FED147',
                    'font-size': '10px',
                    'text-shadow': '0px 0px 5px #000'
                },
                position: data[i].lnglats,
                offset: new AMap.Pixel(12, 20)
            });
            marker.setAnimation('AMAP_ANIMATION_DROP');
            // marker.ExtData = xzArr[i]; // 自定义数据
            marker.content = _this.createInfoWindow(data[i].name, infoClass);
            //marker弹出自定义的信息窗体
            marker.on('mouseover', function (e) {
                _infoWindow.setContent(e.target.content);
                _infoWindow.open(map, e.target.getPosition());
            });
            marker.on('mouseout', function (e) {
                map.clearInfoWindow();
            });
        }
    }
};


/**
 * industriyPark(params)函数调用
 * params --> 标题参数   option--> 坐标，半经 等参数对象
 */
function industriyPark(params) {
    $.ajax({
        url: "/modules/sys/resourceMaps/resourceQuery",
        type: "POST",
        dataType: "json", //返回数据形式为json
        contentType: 'application/json;charset=UTF-8',
        data: JSON.stringify({'type':params}),
        success: function (result) {
            console.log(result);
            var option=[];
            if(result.code==="200"){
                if(result.data !=undefined){
                    for(var i=0;i<result.data.length;i++){
                        var obj = {};
                        obj.lnglats = [result.data[i].longitude,result.data[i].latitude];//经度  维度
                        obj.r = result.data[i].radii;          //半径
                        obj.name = result.data[i].resourceName;      //产业、园区的名字
                        obj['type']=params;
                        option.push(obj);

                    }
                }
            }
            console.log(params);
            console.log(option);
            //调用地图显示区域函数
            aMap.addTour(option);
        }
    });
}


/**
 * [lyClick 旅游点击事件]
 * @return {[type]} [description]
 */
function lyClick() {
    $("#map-img").hide();
    $("#map-img img").attr("src", "./../../../assets/dist/img/lyimg.png");
    map.setMapStyle(mapStyle2);
    map.clearMap();
    aMap.addMapBorder();

    //    旅游请求
    var params="旅游";
    industriyPark(params);


}
/**
 *[nyClick 农业点击时间]
 *
 */
function nyClick() {
    $("#map-img").hide();
    map.setMapStyle(mapStyle2);
    map.clearMap();
    aMap.addMapBorder();

    //  农业请求
    var params="农业";
    industriyPark(params);
}
/**
 *[yqClick 园区点击事件]
 *
 */
function yqClick() {

    $("#map-img").hide();
    map.setMapStyle(mapStyle2);
    map.clearMap();
    aMap.addMapBorder();

    //    园区请求
    var params="园区";
    industriyPark(params);


}






/**
 * [totalRateInit 总完成率]
 * @param {[object]} op [description]
 */
function totalRChartInit(op) {
    var _option = {
        series: [{
            name: "总完成情况",
            type: "pie",
            radius: ["60%", "65%"],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: false,
                    position: "center"
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data: [{
                value: op.totalRateNum1,
                name: op.rate + "%",
                label: {
                    normal: {
                        show: true,
                        textStyle: {
                            color: "#fff",
                            fontSize: "30"
                        }
                    }
                },
                itemStyle: {
                    color: "#56d7ab",
                    shadowBlur: 10,
                    shadowColor: "#56d7ab"
                }
            },
                {
                    value: op.totalRateNum2,
                    name: "剩余",
                    itemStyle: {
                        color: "#fed147",
                        shadowBlur: 10,
                        shadowColor: "#fed147"
                    }
                }
            ]
        }]
    };
    $("#total-rate-num2 em").text(op.totalRateNum1);
    $("#total-rate-num1 em").text(op.totalRateNum2);
    $("#total-rate-num3 em").text(op.totalRateNum1 + op.totalRateNum2);
    var _ec = echarts.init(document.getElementById("zwcl-chart"));
    _ec.setOption(_option);
    resizeChart(_ec);
}

/**
 * [jdtInit 3个进度进度条]
 * @param {[object]} op [description]
 */
// function jdtInit(op) {
//     var $parent = $("#cytz-chart .progress-container");
//     var _total = (op.arr1[0] + op.arr1[1] + op.arr1[2]) / 100;
//
//     $parent
//         .eq(0)
//         .find(".progress-bar-info-1 em")
//         .text(op.arr1[0]);
//     $parent
//         .eq(0)
//         .find(".progress-bar-info-2 em")
//         .text(op.arr1[1]);
//     $parent
//         .eq(0)
//         .find(".progress-bar-info-3 em")
//         .text(op.arr1[2]);
//
//     $parent
//         .eq(0)
//         .find(".progress-bar-info-1")
//         .css("width", "40%");
//     $parent
//         .eq(0)
//         .find(".progress-bar-1")
//         .css("width", op.arr1[0] / _total + "%");
//     $parent
//         .eq(0)
//         .find(".progress-bar-2")
//         .css("width", op.arr1[1] / _total + "%");
//     $parent
//         .eq(0)
//         .find(".progress-bar-3")
//         .css("width", op.arr1[2] / _total + "%");
// }

/**
 * [qyPieInit 企业分类饼图]
 * @param {[object]} op [description]
 */
function qyChartInit(op) {
    var _option = {
        tooltip: {
            trigger: "item"
        },
        legend: {
            orient: "vertical",
            right: 0,
            bottom: "34%",
            // data:option.legend,
            textStyle: {
                color: "#fff"
            },
            data: [{
                name: "民企",
                textStyle: {
                    fontSize: "12"
                }
            },
                {
                    name: "国企",
                    textStyle: {
                        fontSize: "12"
                    }
                }
            ],
            formatter: function (name) {
                if (name === "民企") {
                    return name + "：" + op.dataArr[0] + "项";
                } else if (name === "国企") {
                    return name + "：" + op.dataArr[1] + "项";
                } else if (name === "外企") {
                    return name + "：" + op.dataArr[2] + "项";
                } else {
                    return name + "：" + op.dataArr[3] + "项";
                }
            }
        },
        series: [{
            type: "pie",
            radius: "50%",
            center: ["30%", "50%"],
            label: {
                normal: {
                    show: false
                }
            },
            // data:_this.dataArr,
            data: [{
                value: op.dataArr[0],
                name: "民企",
                itemStyle: {
                    color: "#FED147"
                }
            },
                {
                    value: op.dataArr[1],
                    name: "国企",
                    itemStyle: {
                        color: "#FF6464"
                    }
                }
            ]
        }]
    };
    // var _ec = echarts.init(document.getElementById("qy-chart"));
    // _ec.setOption(_option);
    // resizeChart(_ec);
}

/**
 * [xmqkChartInit 项目情况环形图-5亿]
 * @param {[object]} op [description]
 */
function xmqkChartInit(op) {
    this.dataArr = op.dataArr;
    var _rate1 =
        (op.dataArr[0] / (op.dataArr[0] + op.dataArr[1])).toFixed(3) * 100;
    var _rate2 =
        (op.dataArr[1] / (op.dataArr[0] + op.dataArr[1])).toFixed(3) * 100;
    this.el = op.el;
    var _option = {
        tooltip: {
            trigger: "item"
        },
        legend: {
            orient: "vertical",
            right: 10,
            bottom: "34%",
            textStyle: {
                color: "#fff"
            },

            data: [{
                name: "大项目、好项目",
                textStyle: {
                    fontSize: "10",
                    color: "#fff"
                }
            },
                {
                    name: "一般项目",
                    textStyle: {
                        fontSize: "10",
                        color: "#fff"
                    }
                }
            ],
            formatter: function (name) {
                if (name === "大项目、好项目") {
                    return (
                        name +
                        "：" +
                        op.dataArr[0].num +
                        "项\n" +
                        "金额:" +
                        op.dataArr[0].sum1+"亿"
                    );
                } else {
                    return (
                        name +
                        "：" +
                        op.dataArr[1].num +
                        "项\n" +
                        "金额:" +
                        op.dataArr[1].sum1+"亿"
                    );
                }
            }
        },
        series: [{
            type: "pie",
            radius: ["20%", "45%"],
            center: ["20%", "45%"],
            label: {
                normal: {
                    show: false
                }
            },
            data: [{
                value: op.dataArr[0].num,
                name: "大项目、好项目",
                itemStyle: {
                    color: "#56D7AB"
                }
            },
                {
                    value: op.dataArr[1].num,
                    name: "一般项目",
                    itemStyle: {
                        color: "#FF6464"
                    }
                }
            ]
        }]
    };
    var _ec = echarts.init(document.getElementById("xmqk-chart"));
    _ec.setOption(_option);
    resizeChart(_ec);
}

/**
 * [tzeChart 投资额折线图]
 * @param {[object]} op [description]
 */
function tzeChartInit(op) {
    var _option = {
        tooltip: {
            trigger: "axis",
            axisPointer: {
                type: "shadow"
            }
        },
        legend: {
            data: ["得分"],
            right: 0,
            textStyle: {
                color: "#FED147"
            }
        },
        grid: {
            left: "3%",
            right: "5%",
            top: "10%",
            bottom: "5%",
            containLabel: true
        },
        xAxis: {
            type: "value",
            axisLine: {
                lineStyle: {
                    color: "#fff"
                }
            },
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: "category",
            axisLine: {
                lineStyle: {
                    color: "#fff"
                }
            },
            data: op.xcArr.reverse()
        },
        series: [{
            name: "得分",
            type: "bar",
            data: op.dataArr.reverse(),
            itemStyle: {
                normal: {
                    color: "#FED147",
                    barBorderRadius: 10
                }
            },
            barWidth: 10 //柱图宽度
        }]
    };
    var _ec = echarts.init(document.getElementById("gytz-chart"));
    _ec.setOption(_option);
    resizeChart(_ec);
}

/**
 * [xzdfChart 各乡镇得分柱状图]
 * @param {[object]} op [description]
 */
function xzdfChartInit(op) {
    var _option = {
        tooltip: {
            trigger: "axis",
            axisPointer: {
                type: "shadow"
            }
        },
        legend: {
            data: ["得分"],
            right: 0,
            textStyle: {
                color: "#FED147"
            }
        },
        grid: {
            left: "3%",
            right: "5%",
            top: "7%",
            bottom: "5%",
            containLabel: true
        },
        xAxis: {
            type: "value",
            axisLine: {
                lineStyle: {
                    color: "#fff"
                }
            },
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: "category",
            axisLine: {
                lineStyle: {
                    color: "#fff"
                }
            },
            data: op.xzArr
        },
        series: [{
            name: "得分",
            type: "bar",
            data: op.dataArr,
            itemStyle: {
                normal: {
                    color: "#FED147",
                    barBorderRadius: 10
                }
            },
            barWidth: 10 //柱图宽度
        }]
    };
    var _ec = echarts.init(document.getElementById('gxz-chart'));
    _ec.setOption(_option);
    resizeChart(_ec);
}


/**
 * [allChartInit 图表初始化]
 * @return {[type]} [description]
 */
zyData={}; //专业
xzData={}; //乡镇
bmData={}; //部门
function allChartInit() {
    // 总完成
    $.ajax({
        url:"/chart/show/getTotalRate",
        type :"POST",
        dataType : "json", //返回数据形式为json
        contentType:'application/json;charset=UTF-8',
        data:JSON.stringify({"datatime":""}),
        success:function(result) {
            var totalRateNum1 = result.data.total;
            var totalRateNum2 = result.data.num;
            var rate = result.data.sum1;
            // var totalRateEl = 'zwcl-chart';

            var op1 = {
                totalRateNum1: totalRateNum1,
                totalRateNum2: totalRateNum2,
                rate: rate
                // el: totalRateEl
            };
            totalRChartInit(op1);
        }
    });


    // 产业投资额
    // var op3 = {
    //     arr1: [300.2, 212, 110]
    //     // el: 'cytz-chart'
    // };
    // jdtInit(op3);
    // 企业分类
    // var op4 = {
    //     dataArr: [2, 5, 2, 1]
    //     // el: 'qy-chart'
    // };
    // qyChartInit(op4);

    // 大项目，好项目
    $.ajax({
        url:"/chart/show/eachStageBigGood",
        type :"POST",
        dataType : "json", //返回数据形式为json
        contentType:'application/json;charset=UTF-8',
        data:JSON.stringify({"datatime":""}),
        success:function(result) {
            var op5 = {
                dataArr: [result.data.bigluodi, result.data.goodluodi]
                // el: 'xmqk-chart'
            };
            xmqkChartInit(op5);
        }
    });

    //市考核详情
    // xcArr =["晋安区","闽侯县", "长乐区",  "福清市", "连江县", "鼓楼区", "罗源县", "高新区", "永泰县", "仓山区", "马尾区", "闽清县","台江区"],
    // var op6 = {
    //     dataArr: [85.37, 85.11, 84.28, 72.01, 69.36, 66.26, 64.56, 62, 61.93, 61.82, 61.49,56.62,41.37]
    //     // el: 'gytz-chart'
    // };
    // tzeChartInit(op6);
    $.ajax({
        url:"/modules/sys/CityAssessmentCtrl/queryResource",
        type :"POST",
        dataType : "json", //返回数据形式为json
        contentType:'application/json;charset=UTF-8',
        data:JSON.stringify({"datatime":""}),
        success:function(result) {
            if(result.code=="200"){
                var opt6={};
                var xcArr=[];
                var dataArr=[];
                for(var i=0;i<result.data.length;i++){
                    xcArr.push(result.data[i].county);
                    dataArr.push(result.data[i].point)
                }
                opt6['xcArr']=xcArr;
                opt6['dataArr']=dataArr
                tzeChartInit(opt6);
            }
        }
    });
    //专业排名
    $.ajax({
        url:"/team/teamrank/rank",
        type :"POST",
        dataType : "json", //返回数据形式为json
        contentType:'application/json;charset=UTF-8',
        data:JSON.stringify({"datatime":""}),
        success:function(result) {
            var data=[];
            var zy=[];
            result.rows.map(function (val,index) {
                data.push(val.score);
                var index=val.teamname.indexOf('招')
                var newVal=val.teamname.slice(0,index);
                zy.push(newVal);
            });
            //前三排名
            var ranking=zy[0];
            zyData['dataArr']=data.reverse();
            zyData['xzArr']=zy.reverse();
            xzdfChartInit(zyData);
        }
    });
    //乡镇排名
    $.ajax({
        url:"/team/teamrank/rankQuery",
        type :"POST",
        dataType : "json", //返回数据形式为json
        contentType:'application/json;charset=UTF-8',
        data:JSON.stringify({'teamClass' : '乡镇'}),
        success:function(result) {
            var data=[];
            var xz=[];
            result.data.map(function (val,index) {
                data.push(val.score);
                xz.push(val.teamname);
            })
            xzData['dataArr']=data.reverse();
            xzData['xzArr']=xz.reverse();
        }
    });
    //部门排名
    $.ajax({
        url:"/team/teamrank/rankQuery",
        type :"POST",
        dataType : "json", //返回数据形式为json
        contentType:'application/json;charset=UTF-8',
        data:JSON.stringify({'teamClass' : '部门'}),
        success:function(result) {
            var data=[];
            var bm=[];
            result.data.map(function (val,index) {
                data.push(val.score);
                bm.push(val.teamname);
            })
            bmData['dataArr']=data.reverse();
            bmData['xzArr']=bm.reverse();
        }
    });
}
function xzClick(){
    xzdfChartInit(xzData);
}
function gbmClick() {
    xzdfChartInit(bmData);
}
function zyClick() {
    xzdfChartInit(zyData);
}
